package org.subatu.orm;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.subatu.orm.entity.UserPo;
import org.subatu.orm.mapper.UserMapper;

import java.time.LocalDateTime;

@SpringBootTest
public class UserMapperTester {

    @Autowired
    private UserMapper userMapper;

    @Test
    public void save() {
        UserPo user = new UserPo();
        // user.setObjectId("123");
        int save = userMapper.save(user);
        System.out.println("save = " + save);
        System.out.println("user = " + user);

    }

    @Test
    public void deleteRealObj() {
        UserPo user = new UserPo();
        user.setObjectId("1736216058592890880");

        int i = userMapper.deleteRealById(user);
        System.out.println("i = " + i);

    }

    @Test
    public void deleteReal() {
        int i = userMapper.deleteRealById("1736272399537672192");
        System.out.println("i = " + i);
    }

    @Test
    public void delete() {
        int i = userMapper.deleteById("1736272399537672192");
        System.out.println("i = " + i);

    }

    @Test
    public void deleteObj() {
        UserPo userPo = userMapper.getById("1736272399537672192");
        int i = userMapper.deleteById(userPo);
        System.out.println("i = " + i);
    }

    @Test
    public void getById() {
        UserPo userPo = userMapper.getById("1736272399537672192");
        System.out.println("userPo = " + userPo);
    }

    @Test
    public void updateById() {
        UserPo userPo = userMapper.getById("1736272399537672192");
        userPo.setUpdateTime(LocalDateTime.now());
        userMapper.updateById(userPo);
    }
}
